// =====================================================================================
// Copyright ?2006 SmartCodeGenerator created by Shahed Khan. 
/*
//Microsoft Shared Source Community License (MS-CL)
//Published: October 18, 2005
*/
// If you like this code then feel free to go ahead and use it.
// Your use of this software is entirely at your own risk.
// I make no claims or warrantees about the reliability or fitness of this code for any particular purpose.
// website www.smartcodegenerator.com, email shahed.khan@gmail.com
// =====================================================================================

using System;
using System.Collections.Generic;
using System.Text;

namespace SmartCodeGen.Providers
{
    [Serializable]
    public class DatabaseSchema: SchemaBase
    {
        // Methods
        public DatabaseSchema( )         
        {
            //this.a = null;
            //this.a = new StringCollection();
            //this.a = string.Empty;
            //this.b = string.Empty;
            //this.a = false;
            base.database = this;
            //this.a();

        }
        public DatabaseSchema(string connectionString):this() 
        {
            base.connectionString = connectionString;
        }

        public DatabaseSchema(DBSchemaProvider provider, string connectionString)
            : this()
        {
            base.connectionString = connectionString;
            base.databaseSchemaProvider = provider;
        }
        //public DatabaseSchema(IDbSchemaProvider provider, string connectionString) 
        //{ }       
        //public IDbSchemaProvider GetProvider(string name)
        //{
        //    throw new NotImplementedException();
        //}
        //public IDbSchemaProviderCollection GetProviders( )
        //{
        //    throw new NotImplementedException();
        //}
       
        public override string ToString( )
        {
            return this.Name;
        }

      // Properties

        CommandSchemaCollection commands;
        public CommandSchemaCollection Commands 
        { 
            get
            {
                if (this.commands == null)
                {
                    //this.c();
                    CommandSchemaCollection collection1 = DBSchema.GetCommands(this);
                    //this.commands = CommandSchemaCollection.ReadOnly(collection1);
                    this.commands = collection1;
                }
                return this.commands;

            }
        }
        
        public new string ConnectionString
        {
            get
            {
                return this.connectionString;
            }
            set
            {
                //this.b();
                this.connectionString = value;
                
            }
        }

        public new DBSchemaProvider DatabaseSchemaProvider
        {
            get
            {
                return this.databaseSchemaProvider;
            }
            set
            {
                //this.b();
                this.databaseSchemaProvider = value;

            }
        }

        
        public override string Name
        {
            get
            {
                //if (!this.a)
                {
                    //this.c();
                    this.name = DBSchema.GetDatabaseName(this);
                    //this.a = true;
                }
                return this.name;

            }
        }



        TableSchemaCollection tables;
        public TableSchemaCollection Tables
        {
            get
            {
                if (this.tables == null)
                {
                    //this.c();
                    TableSchemaCollection collection1 = DBSchema.GetTables(this);
                    //this.tables = TableSchemaCollection.ReadOnly(collection1);
                    this.tables = collection1;
                }
                return this.tables;

            }
        }

        ViewSchemaCollection views;
        public ViewSchemaCollection Views
        {
            get
            {
                if (this.views == null)
                {
                    //this.c();
                    ViewSchemaCollection collection1 = DBSchema.GetViews(this);
                    //this.views = ViewSchemaCollection.ReadOnly(collection1);
                    this.views = collection1;
                }
                return this.views;

            }
        }
    }
}
